package com.winsdom.mapper;

import com.winsdom.dto.CategoryTreeNodes;
import com.winsdom.dto.ResourceDTO;
import com.winsdom.entity.Category;
import com.winsdom.entity.Resource;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 资源信息表 Mapper 接口
 * </p>
 *
 * @author 
 * @since 2025-05-12
 */
@Mapper
public interface ResourceMapper extends BaseMapper<Resource> {


    @Select("SELECT * FROM category WHERE id = #{id} AND status = 1")
    CategoryTreeNodes getNodeById(Long id);

    // 查询指定节点下所有type<=5的子节点
    @Select("SELECT * FROM category WHERE parent_id = #{parentId} AND type <= 5 AND status = 1")
    List<CategoryTreeNodes> getChildrenByParentId(Long parentId);
    //查询指定节点下所有type<=6的子节点
    @Select("SELECT * FROM category WHERE parent_id = #{parentId} AND type <= 6 AND status = 1")
    List<CategoryTreeNodes> getChildrenByParentId1(Long parentId);

    void update(Resource resource);

    @Select("SELECT * FROM resource WHERE id = #{id} AND resource_status !='已停用' ")
    Resource getById(Long id);


    List<Resource> getByCategoryId(@Param("categoryIds") List<Long> categoryIds);

    List<Long> getauthorizedBuildingIds(Long userId);
}
